/**
 * Copyright (c) 2016-2021 by the respective copyright holders.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package com.zsmartsystems.zigbee.zdo.command;

import javax.annotation.Generated;

import com.zsmartsystems.zigbee.IeeeAddress;
import com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer;
import com.zsmartsystems.zigbee.zcl.ZclFieldSerializer;
import com.zsmartsystems.zigbee.zcl.protocol.ZclDataType;
import com.zsmartsystems.zigbee.zdo.ZdoRequest;

/**
 * Management Direct Join Request value object class.
 * <p>
 * <p>
 * The Mgmt_Direct_Join_req is generated from a Local Device requesting that a Remote Device
 * permit a device designated by DeviceAddress to join the network directly. The
 * Mgmt_Direct_Join_req is generated by a management application which directs the request
 * to a Remote Device where the NLME-DIRECTJOIN.request is to be executed using the parameter
 * supplied by Mgmt_Direct_Join_req.
 * <p>
 * Code is auto-generated. Modifications may be overwritten!
 */
@Generated(value = "com.zsmartsystems.zigbee.autocode.ZigBeeCodeGenerator", date = "2020-12-25T10:11:19Z")
public class ManagementDirectJoinRequest extends ZdoRequest {
    /**
     * The ZDO cluster ID.
     */
    public static int CLUSTER_ID = 0x0035;

    /**
     * Device Address command message field.
     */
    private IeeeAddress deviceAddress;

    /**
     * Capability Information command message field.
     */
    private Integer capabilityInformation;

    /**
     * Default constructor.
     *
     * @deprecated from release 1.3.0. Use the parameterised constructor instead of the default constructor and setters.
     */
    @Deprecated
    public ManagementDirectJoinRequest() {
        clusterId = CLUSTER_ID;
    }

    /**
     * Constructor providing all required parameters.
     *
     * @param deviceAddress {@link IeeeAddress} Device Address
     * @param capabilityInformation {@link Integer} Capability Information
     */
    public ManagementDirectJoinRequest(
            IeeeAddress deviceAddress,
            Integer capabilityInformation) {

        clusterId = CLUSTER_ID;

        this.deviceAddress = deviceAddress;
        this.capabilityInformation = capabilityInformation;
    }

    /**
     * Gets Device Address.
     *
     * @return the Device Address
     */
    public IeeeAddress getDeviceAddress() {
        return deviceAddress;
    }

    /**
     * Sets Device Address.
     *
     * @param deviceAddress the Device Address
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setDeviceAddress(final IeeeAddress deviceAddress) {
        this.deviceAddress = deviceAddress;
    }

    /**
     * Gets Capability Information.
     *
     * @return the Capability Information
     */
    public Integer getCapabilityInformation() {
        return capabilityInformation;
    }

    /**
     * Sets Capability Information.
     *
     * @param capabilityInformation the Capability Information
     * @deprecated as of 1.3.0. Use the parameterised constructor instead to ensure that all mandatory fields are provided.
     */
    @Deprecated
    public void setCapabilityInformation(final Integer capabilityInformation) {
        this.capabilityInformation = capabilityInformation;
    }

    @Override
    public void serialize(final ZclFieldSerializer serializer) {
        super.serialize(serializer);

        serializer.serialize(deviceAddress, ZclDataType.IEEE_ADDRESS);
        serializer.serialize(capabilityInformation, ZclDataType.BITMAP_8_BIT);
    }

    @Override
    public void deserialize(final ZclFieldDeserializer deserializer) {
        super.deserialize(deserializer);

        deviceAddress = (IeeeAddress) deserializer.deserialize(ZclDataType.IEEE_ADDRESS);
        capabilityInformation = (Integer) deserializer.deserialize(ZclDataType.BITMAP_8_BIT);
    }

    @Override
    public String toString() {
        final StringBuilder builder = new StringBuilder(104);
        builder.append("ManagementDirectJoinRequest [");
        builder.append(super.toString());
        builder.append(", deviceAddress=");
        builder.append(deviceAddress);
        builder.append(", capabilityInformation=");
        builder.append(String.format("%02X", capabilityInformation));
        builder.append(']');
        return builder.toString();
    }

}
